import javax.swing.*; // Needed for Swing classes import java.awt.*; // Needed for GridLayout class import java.awt.event.ActionListener; import java.awt.event.ActionEvent; public class BirthYear extends JFrame { private int WINDOW_WIDTH = 1200; // WIndow width private int WINDOW_HEIGHT=1400; // Window height private JComboBox birthMonth; // JCombo Box contain Integer of birth Month private JComboBox birthDay; // JCombo Box contain Integer of birth Days private JComboBox birthYear; // JCombo Box contain Integer of birth Year public BirthYear() { // Set the title bar text. setTitle("Nine Start Ki Astrology "); // Set the size of the window. setSize(WINDOW_WIDTH,WINDOW_HEIGHT); // Specify an action for the close button. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Add a GridLayout manager to the content pane. setLayout(new GridLayout(5,3)); monthsAndYear(); // Create 15 panels JPanel WaterPanel = new JPanel(); JPanel EarthPanel = new JPanel(); JPanel ThunderPanel = new JPanel(); JPanel WindPanel = new JPanel(); JPanel EarthquakePanel = new JPanel(); JPanel UniversePanel = new JPanel(); JPanel LakePanel = new JPanel(); JPanel MountainPanel = new JPanel(); JPanel FirePanel = new JPanel(); JPanel monthPanel = new JPanel(); JPanel daysPanel = new JPanel(); JPanel yearPanel = new JPanel(); JPanel emptyLeft = new JPanel(); JPanel buttonPanel = new JPanel(); JPanel emptyRight = new JPanel(); // Create 12labels JLabel Water = new JLabel("???? \n(WATER) "); JLabel Earth= new JLabel("???? \n(EARTH)"); JLabel Thunder = new JLabel("???? \n(THUNDER)"); JLabel Wind = new JLabel("???? \n(WIND)"); JLabel Earthquake = new JLabel("???? \n(EARTHQUAKE)"); JLabel Universe = new JLabel("???? \n(UNIVERSE)"); JLabel Lake = new JLabel("???? \n(LAKE)"); JLabel Mountain = new JLabel("???? \n(MOUNTAIN)"); JLabel Fire = new JLabel("???? \n(FIRE)"); JLabel monthMessage = new JLabel(" Month"); JLabel daysMessage = new JLabel("Days"); JLabel yearMessage= new JLabel(" Year "); JLabel emptyMessageLeft = new JLabel(" "); JLabel buttonMessage = new JLabel("This will determine your sign "); JLabel emptyMessageRight = new JLabel(" "); // Change font and size Water.setFont(new Font("Serif",Font.ITALIC,30)); Earth.setFont(new Font("Serif",Font.ITALIC,30)); Thunder.setFont(new Font("Serif",Font.ITALIC,30)); Wind.setFont(new Font("Serif",Font.ITALIC,30)); Earthquake.setFont(new Font("Serif",Font.ITALIC,30)); Universe.setFont(new Font("Serif",Font.ITALIC,30)); Lake.setFont(new Font("Serif",Font.ITALIC,30)); Mountain.setFont(new Font("Serif",Font.ITALIC,30)); Fire.setFont(new Font("Serif",Font.ITALIC,30)); monthMessage.setFont(new Font("Serif",Font.ITALIC,30)); daysMessage.setFont(new Font("Serif", Font.ITALIC,30)); yearMessage.setFont(new Font("Serif",Font.ITALIC,30)); buttonMessage.setFont(new Font("Serif",Font.ITALIC,30)); // change combo box size birthMonth.setPreferredSize(new Dimension(110,30)); birthDay.setPreferredSize(new Dimension(110,30)); birthYear.setPreferredSize(new Dimension(110,30)); // Creating button JButton button= new JButton("Determine"); // Add the labels to the panels WaterPanel.add(Water); EarthPanel.add(Earth); ThunderPanel.add(Thunder); WindPanel.add(Wind); EarthquakePanel.add(Earthquake); UniversePanel.add(Universe); LakePanel.add(Lake); MountainPanel.add(Mountain); FirePanel.add(Fire); monthPanel.add(monthMessage); monthPanel.add(birthMonth); daysPanel.add(daysMessage); daysPanel.add(birthDay); yearPanel.add(yearMessage); yearPanel.add(birthYear); emptyLeft.add(emptyMessageLeft); buttonPanel.add(buttonMessage); emptyRight.add(emptyMessageRight); // Add the buttons to the panels buttonPanel.add(button); // Add the panels to the content pane. add(WaterPanel); add(EarthPanel); add(ThunderPanel); add(WindPanel); add(EarthquakePanel); add(UniversePanel); add(LakePanel); add(MountainPanel); add(FirePanel); add(monthPanel); add(daysPanel); add(yearPanel); add(emptyLeft); add(buttonPanel); add(emptyRight); // Add an action listener to JCombo Month, Days, and the button. // birthMonth.addActionListener(new MonthSelectionListener()); // birthDay.addActionListener(new DaysSelectionListener()); // birthYear.addActionListener(new YearSelectionListener()); button.addActionListener(new DetermineButtonListener()); // Display the window. setVisible(true); } public void monthsAndYear() { // Create Array list for Month's selections // JCombobox does not support primitive data type,so used Integer array Integer[] months = new Integer[12]; // loop to create selections for combo box for(int i=0; i(months); // Create Array list for Days' selections Integer[] days = new Integer[31]; // loop to create selection for combo box for(int i=0; i(days); // Create Array list for Year's selections Integer[] year = new Integer[117]; // loop to create selections for combo box for(int i=0; i(year); } private class DetermineButtonListener implements ActionListener { public void actionPerformed(ActionEvent e) { birthMonth = (JComboBox)e.getSource(); //Description userDescription = new Description( birthMonth.getSelectedItem(),birthDay.getSelectedItem(),birthYear.getSelectedItem()); } } }